package com.hp.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hp.mapper.AlbumMapper;
import com.hp.pojo.Album;
import com.hp.service.AlbumService;
import com.hp.util.PageResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AlbumServiceImpl implements AlbumService {

    @Resource
    private AlbumMapper albumMapper;

    @Override
    public PageResult findList(int pageNum,int pageSize,Album album) {
        PageHelper.startPage(pageNum, pageSize);
        Page<Album> page = (Page<Album>)albumMapper.findList(album);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void add(Album album) {
        albumMapper.add(album);
    }

    @Override
    public Album findById(int id) {
        return albumMapper.findById(id);
    }

    @Override
    public void update(Album album) {
        albumMapper.update(album);
    }

    @Override
    public void delete(int id) {
        albumMapper.delete(id);
    }

    @Override
    public String getimageItems(int id) {
        Album album = albumMapper.findById(id);
        return album.getImageItems();
    }
}
